//删除管理员路游
const express = require("express");
const route = express.Router();
//引入集合
const AdminModule = require("../mongoose/module/index");
//权限验证
const isLogin = require("../verify/isLogin");
//解析请求体中间件
route.use(express.json());
route.use(express.urlencoded());

//配置请求信息
route.delete("/deleteAdmin",isLogin ,async (request, response) => {
 
  let adminName = request.query.adminName;
  try {
    const re = await AdminModule.deleteOne({
      adminName,
    });
    //re.deletedCount删除的个数
    if (re.deletedCount > 0) {
      response.send({
        code: 200,
        data: null,
        message: "删除成功",
      });
    }
  } catch (error) {
    response.send({
      code: 201,
      data: null,
      message: "删除失败",
    });
  }
});

module.exports = route;
